package com.itheima.案例;

import java.util.ArrayList;

public class StudentOperatorlmpl2 implements  StudentOperator  {
    @Override
  public void printAverage(ArrayList<Student> list) {
                double allScore = 0;
        for (int i = 0; i < list.size(); i++) {
            Student student = list.get(i);
            allScore += student.getScore();
        }
        System.out.println("平均成绩为：" + allScore / list.size());
    }

    @Override
    public void printInfo(ArrayList<Student> list) {
        System.out.println("-----------全班全部学生信息如下-------------");
        int count1=0;
        int count2=0;
        for (int i = 0; i < list.size(); i++) {
            Student student = list.get(i);
            System.out.println(student.toString());//
            if(student.getSex()=='男'){//统计男生的个数
                count1++;
            }else{
                count2++;
        System.out.println("男生人数："+count1);
        System.out.println("女生人数："+count2);
            System.out.println("----------------------------------------");
        }
    }

//    @Override
//    public void printAverage(ArrayList<Student> list) {
//        double allScore = 0;
//        for (int i = 0; i < list.size(); i++) {
//            Student student = list.get(i);
//            allScore += student.getScore();
//        }
//        System.out.println("平均成绩为：" + allScore / list.size());
   }
}
